import { Suspense, lazy } from 'react'
import { CircleLoading } from '@/components/loading'
import DashboardLayout from '../../../layouts/dashboard'
import { Navigate, Outlet } from 'react-router-dom'
const DeptIndex = lazy(() => import(`@/pages/System/dept/index`))
const DictIndex = lazy(() => import(`@/pages/System/dict/index`))
const UserIndex = lazy(() => import(`@/pages/System/user/index`))
const RoleIndex = lazy(() => import(`@/pages/System/role/index`))
const SysAppIndex = lazy(() => import(`@/pages/System/sysApp/index`))
const AppMenuIndex = lazy(() => import(`@/pages/System/appMenu/index`))
const AppMenuDetail = lazy(() => import(`@/pages/System/appMenu/detail`))
const PageConfigIndex = lazy(() => import(`@/pages/System/pageConfig/index`))
const PageConfigDetail = lazy(() => import(`@/pages/System/pageConfig/detail`))
const JobIndex = lazy(() => import(`@/pages/monitor/job/index`))
const JobLogIndex = lazy(() => import(`@/pages/monitor/job/logIndex`))
const OperlogIndex = lazy(() => import(`@/pages/monitor/operlog/index`))
const AppJwtIndex = lazy(() => import(`@/pages/appjwt/index`))

// 集成共享
const DataSourceIndex = lazy(() => import(`@/pages/sharing/dataSource`))
const DataSubjectIndex = lazy(() => import(`@/pages/sharing/dataSubject`))
const DataSubjectDetail = lazy(() => import(`@/pages/sharing/dataSubject/detail`))
const DataSubjectDesign = lazy(() => import(`@/pages/sharing/dataSubject/design`))
const DataCatalogIndex = lazy(() => import(`@/pages/sharing/dataCatalog`))
const DataCatalogDetail = lazy(() => import(`@/pages/sharing/dataCatalog/detail`))
const DataCatalogEdit = lazy(() => import(`@/pages/sharing/dataCatalog/edit`))
const DataCatalogTryout = lazy(() => import(`@/pages/sharing/dataCatalog/tryout`))
const ServiceCatalogIndex = lazy(() => import(`@/pages/sharing/serviceCatalog`))
const ServiceCatalogDetail = lazy(() => import(`@/pages/sharing/serviceCatalog/detail`))
const ServiceCatalogEdit = lazy(() => import(`@/pages/sharing/serviceCatalog/edit`))
const ServiceCatalogTryout = lazy(() => import(`@/pages/sharing/serviceCatalog/tryout`))
const ServiceCatalogAdd = lazy(() => import(`@/pages/sharing/serviceCatalog/add`))
const RedisIndex = lazy(() => import(`@/pages/sharing/redis`))

const ServiceFlowIndex = lazy(() => import(`@/pages/sharing/serviceFlow`))
const ServiceFlowDesign = lazy(() => import(`@/pages/sharing/serviceFlow/flowDesign`))


function Wrapper() {
    return (
        <Suspense fallback={<CircleLoading />}>
            <Outlet />
        </Suspense>
    )
}

const management = {
    element: <DashboardLayout />,
    children: [
        // {
        //     path: 'integration/mixture',
        //     element: <MixtureIndex />,
        // },
        {
            path: 'integration/iot',
            element: <Wrapper />,
            children: [
                {
                    path: 'dept',
                    element: <DeptIndex />,
                },
                {
                    path: 'dict',
                    element: <DictIndex />,
                },
            ],
        },
        {
            path: 'integration/monitor',
            element: <Wrapper />,
            children: [
                {
                    path: 'job',
                    element: <JobIndex />,
                },
            ],
        },
        {
            path: 'integration/auth',
            element: <Wrapper />,
            children: [
                {
                    path: 'user',
                    element: <UserIndex />,
                },
                {
                    path: 'role',
                    element: <RoleIndex />,
                },
                {
                    path: 'appJwt',
                    element: <AppJwtIndex />,
                },
            ],
        },
        {
            path: 'integration/org',
            element: <Wrapper />,
            children: [
                {
                    path: 'app',
                    element: <SysAppIndex />,
                },
                {
                    path: 'appMenuResources',
                    element: <AppMenuIndex />,
                },
                {
                    path: 'appMenuResources',
                    element: <AppMenuIndex />,
                },
                {
                    path: 'appMenuResourcesDetail',
                    element: <AppMenuDetail />,
                },
                {
                    path: 'pageConfig',
                    element: <PageConfigIndex />,
                },
                {
                    path: 'pageConfigDetail',
                    element: <PageConfigDetail />,
                },
            ],
        },
        {
            path: 'integration/log',
            element: <Wrapper />,
            children: [
                {
                    path: 'joblog',
                    element: <JobLogIndex />,
                },
                {
                    path: 'operlog',
                    element: <OperlogIndex />,
                },
            ],
        },
        {
            path: 'integration/sharing',
            element: <Wrapper />,
            children: [
                { index: true, element: <Navigate to={'/integration/sharing/dataCatalog'} replace /> },
                {
                    path: 'dataSource',
                    children: [{ index: true, element: <DataSourceIndex /> }],
                },
                {
                    path: 'dataSubject',
                    children: [
                        { index: true, element: <DataSubjectIndex /> },
                        {
                            path: ':id',
                            element: <DataSubjectDetail />,
                        },
                        {
                            path: ':id/design',
                            element: <DataSubjectDesign />,
                        },
                    ],
                },
                {
                    path: 'dataCatalog',
                    children: [
                        { index: true, element: <DataCatalogIndex /> },
                        {
                            path: 'create',
                            element: <DataCatalogEdit />,
                        },
                        {
                            path: ':id',
                            element: <DataCatalogDetail />,
                        },
                        {
                            path: ':id/edit',
                            element: <DataCatalogEdit />,
                        },
                        {
                            path: ':id/tryout',
                            element: <DataCatalogTryout />,
                        },
                    ],
                },
                {
                    path: 'serviceCatalog',
                    children: [
                        { index: true, element: <ServiceCatalogIndex /> },
                        {
                            path: ':id',
                            element: <ServiceCatalogDetail />,
                        },
                        {
                            path: ':id/edit',
                            element: <ServiceCatalogEdit />,
                        },
                        {
                            path: ':id/tryout',
                            element: <ServiceCatalogTryout />,
                        },
                        {
                            path: 'add',
                            element: <ServiceCatalogAdd />,
                        },
                    ],
                },
                {
                    path: 'redis',
                    children: [
                        { index: true, element: <RedisIndex /> },
                        {
                            path: ':id',
                            element: <ServiceCatalogDetail />,
                        },
                        {
                            path: ':id/edit',
                            element: <ServiceCatalogEdit />,
                        },
                        {
                            path: ':id/tryout',
                            element: <ServiceCatalogTryout />,
                        },
                        {
                            path: 'add',
                            element: <ServiceCatalogAdd />,
                        },
                    ],
                },
                {
                    path: 'kafka',
                    children: [
                        { index: true, element: <ServiceCatalogIndex /> },
                        {
                            path: ':id',
                            element: <ServiceCatalogDetail />,
                        },
                        {
                            path: ':id/edit',
                            element: <ServiceCatalogEdit />,
                        },
                        {
                            path: ':id/tryout',
                            element: <ServiceCatalogTryout />,
                        },
                        {
                            path: 'add',
                            element: <ServiceCatalogAdd />,
                        },
                    ],
                },
                {
                    path: 'serviceFlow',
                    children: [
                        { index: true, element: <ServiceFlowIndex /> },
                        {
                            path: 'design/:id',
                            element: <ServiceFlowDesign />,
                        },
                    ],
                }
            ],
        },
    ],
}

export default management
